﻿Public Class frmFlipper

    Private Sub frmFlipper_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Randomize() 'Needed for Random Numbers
    End Sub

    Private Sub btnAgain_Click(sender As System.Object, e As System.EventArgs) Handles btnAgain.Click
        lbxOut.Items.Clear() 'Clear the ListBox
    End Sub

    Private Sub btnStart_Click(sender As System.Object, e As System.EventArgs) Handles btnStart.Click
        'Declare Variables
        Dim Heads As Integer 'Number of "Heads" results
        Dim Tails As Integer 'Number of "Tails" results
        Dim Results As Integer 'Value of the Random stored for each flip
        Dim FlipCounter As Integer 'Number to be set for our Flip Count

        For FlipCounter = 1 To 100 'Do 100 times
            Results = Int((2 - 1 + 1) * Rnd()) + 1
            If Results = "1" Then
                Heads += 1 'Increase the Count of Heads by 1
            Else
                Tails += 1 'Increase the Count of Tails by 1
            End If
        Next FlipCounter
        lbxOut.Items.Add("Heads" & " " & Heads & vbTab & "Tails" & " " & Tails) 'Output the results of the coin flips.
    End Sub
End Class
